package com.stmt.analytic.graph.algorithm.dc;

import java.util.ArrayList;
import java.util.Collection;

public class DegreeCentralityResults {
    private Collection<DegreeCentralityResult> result;

    protected DegreeCentralityResults() {
        this.result = new ArrayList<>();
    }

    public void set(String ovid, double score) {
        result.add(new DegreeCentralityResult(ovid, score));
    }

    public Collection<DegreeCentralityResult> unwrap(){
        return result;
    }

    @Override
    public String toString() {
        return "DegreeCentralityResults{" +
                "result=" + result +
                '}';
    }

    public static final class DegreeCentralityResult implements Comparable<DegreeCentralityResult> {

        private String ovid;

        private double score;

        public DegreeCentralityResult(String ovid, double score) {
            this.ovid = ovid;
            this.score = score;
        }

        public String getOvid() {
            return ovid;
        }

        public double getScore() {
            return score;
        }

        @Override
        public int compareTo(DegreeCentralityResult o) {
            return this.score < o.score ? -1 : ((o.score == this.score) ? 0 : 1);
        }

        @Override
        public String toString() {
            return "DegreeCentralityResult{" +
                    "ovid='" + ovid + '\'' +
                    ", score=" + score +
                    '}';
        }
    }
}
